package com.example.Lezedata.ui.tabBar;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.Nullable;

import com.example.Lezedata.R;
import com.example.Lezedata.dataManager.LoginManager;
import com.example.Lezedata.ui.activity.baseClass.GBBaseVc;
import com.example.Lezedata.ui.activity.login.LoginVc;
import com.example.Lezedata.ui.annPage.AnnPageFragment;
import com.example.Lezedata.ui.dataPage.DataPageFragment;
import com.example.Lezedata.ui.dataPage.DataPageSuperFragment;
import com.example.Lezedata.ui.mePage.MePageFragment;
import com.example.Lezedata.ui.orderPage.OrderPageFragment;
import com.example.Lezedata.util.GBToast;

public class GBTabBarVc extends GBBaseVc {
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        needAddViewToSuperView = false;
        if (LoginManager.instance().loginStatus() != LoginManager.LoginStatus_login){
            jumpActivity(LoginVc.class);
            finish();
        }

        super.onCreate(savedInstanceState);
        setContentView(R.layout.tab_bar);
        baseContentView = findViewById(R.id.contentView);
        initBottomBar();
    }

    void initBottomBar(){
        BottomBar bottomBar = findViewById(R.id.bottom_bar);
        bottomBar.touchEventListener = new BottomBar.onTouchEventListener() {
            @Override
            public boolean shouldResponseEventForIndex(int index) {
//                if ( index == 3){
//                    GBToast.shortToast("功能暂未开放!");
//                    return false;
//                }
                return true;
            }
        };
        bottomBar.setFirstChecked(2);
        bottomBar.setContainer(R.id.contentView)
                .setTitleBeforeAndAfterColor("#999999", "#FF1A1A1A")
                .addItem(AnnPageFragment.class,
                        "资讯",
                        R.drawable.tab_ann_normal,
                        R.drawable.tab_ann_selected)
                .addItem(OrderPageFragment.class,
                        "订单",
                        R.drawable.tab_order_normal,
                        R.drawable.tab_order_selected)
                .addItem(DataPageSuperFragment.class,
                        "统计",
                        R.drawable.tab_data_normal,
                        R.drawable.tab_data_selected)
                .addItem(MePageFragment.class,
                        "我的",
                        R.drawable.tab_me_normal,
                        R.drawable.tab_me_selected)
                .build();
    }
}
